﻿using MediatR;
using MS.Data.API.Write.Applicant.Command.User;
using MS.Data.ErrorCode;
using MS.Data.Infratructrue.Istanbul;

namespace MS.Data.API.Write.Applicant.CommandHandel.User
{
    public class DelUserCommandHandler : IRequestHandler<DelUserCommand, APIResult<int>>
    {
        private readonly IBaseRepository<Domain.User> repository;

        public DelUserCommandHandler(IBaseRepository<Domain.User> repository)
        {
            this.repository = repository;
        }

        public async Task<APIResult<int>> Handle(DelUserCommand request, CancellationToken cancellationToken)
        {
            var list = await repository.Bysty(request.UserId);
            list.IsDel = true;

            await repository.Update(list);

            return new APIResult<int>()
            {
                code = APIEnum.删除成功,
                data = 1,
                mes = ""
            };

        }
    }
}
